<div class="common-document-outer">
  <div class="main-content">
    <div class="search-info">
      <div class="container-header fs-16">
        <span>文件列表</span>
      </div>
      <form class="base-info">
        <input type="hidden" class="pa-form-control-input"
          ng-model="vm.mapParams.orgId">
          <input type="hidden" class="pa-form-control-input"
            ng-model="vm.mapParams.type">
        <div class="base-info-item">
          <div class="pa-form-control">
            <label>资料名称：</label>
            <input type="text" class="pa-form-control-input"
              ng-model="vm.mapParams.documentName">
          </div>
          <div class="pa-form-control">
            <label>资料编号：</label>
            <input type="text" class="pa-form-control-input"
              ng-model="vm.mapParams.documentNumber">
          </div>
          <div class="pa-form-control pa-form-control-btn fr">
            <button class="pa-btn pa-sw-btn" type="button"
              ng-click="vm.$paginationQuery()">搜索</button>
            <button class="pa-btn pa-sw-btn reset-btn" type="reset"
              ng-click="vm.$reset()">重置</button>
          </div>
        </div>
      </form>
    </div>
    <div class="pa-fl">
      <div class="pa-operate-fr fs-theme-color"
        ng-click="vm.$goTable()">
        <i class="iconfont icon-middle icon-chuangjian-copy fs-14"></i>
        <span>新增流程/表单</span>
      </div>
      <div class="pa-operate-fr fs-theme-color"
        ng-click="vm.$addDocument(vm)">
        <i class="iconfont icon-middle icon-22 fs-14"></i>
        <span>新增资料</span>
      </div>
    </div>
    <pa-table>
      <table class="pa-table" data-expand-detail>
        <thead>
          <tr>
            <th class="table-text-left">资料编号</th>
            <th>资料名称</th>
            <th class="sorting"
              ng-class="{'sorting-desc': vm.mapParams.sortType == 2, 'sorting-asc': vm.mapParams.sortType == 1}"
              ng-click="vm.$toggleOrder('compile_time')">
              编制时间
            </th>
            <th class="operate-three">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="item in vm.resource.documentList" data-expand>
            <td class="table-text-left table-text-alignment">{{item.documentNumber}}</td>
            <td>{{item.documentName}}</td>
            <td>{{item.compileTime | date:"yyyy-MM-dd"}}</td>
            <td data-hide="上传人: ">
              {{item.creatorName}}
            </td>
            <td data-hide="附件: ">
              <div class="file-list-folding">
                <div class="file-item" ng-repeat="file in item.files">
                  <span class="file-item-span fl">{{file.fileName}}</span>
                  <a class="pa-btn file-del-btn" target="_blank"
                    ui-sref="documentPreview({id: file.id})">预览</a>
                  <a class="pa-btn file-del-btn" target="_blank"
                    ng-href="{{vm.getDownloadSrc(file.id)}}" download="{{file.fileName}}">下载</a>
                </div>
              </div>
            </td>
            <td data-hide="">
              <div class="file-list-folding"
                ng-show="item.documentSourceType == 1">
                <div class="file-item">
                  <span class="file-item-span fl">{{item.safetyTableRecordPO.recordName}}</span>
                  <a class="pa-btn file-del-btn"
                    ui-sref="iterationDisabledTable({recordId: item.safetyTableRecordPO.id, type: 3})">预览</a>
                </div>
              </div>
            </td>
            <td data-hide="">
              <div class="file-list-folding"
                ng-show="item.documentSourceType == 2">
                <div class="file-item">
                  <span class="file-item-span fl">{{item.safetyTableRecordPO.recordName}}</span>
                  <a class="pa-btn file-del-btn"
                    ui-sref="processTableDetail({tableId: item.safetyTableRecordPO.id, name: vm.view.box.name, piId: item.piId})">预览</a>
                </div>
              </div>
            </td>
            <td>
              <!-- <div class="operate-del" ng-click="vm.$viewDocument(item, vm)">
                <i class="iconfont icon-jilu3 detail-color fs-12"></i>
                <span>详情</span>
              </div> -->
              <div class="operate-del" ng-click="vm.$editDocument(item, vm)">
                <i class="iconfont icon-xiugai1 edit-color fs-12"></i>
                <span>修改</span>
              </div>
              <div class="operate-del" ng-click="vm.$delete(item.id)">
                <i class="iconfont icon-shanchu trash-color fs-12"></i>
                <span>删除</span>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
    </pa-table>
  </div>
  <!-- 新增弹窗 -->
  <script type="text/ng-template" id="paAddDialog">
    <div class="pa-dialog">
      <div class="pa-dialog-header">
        <div class="title-txt">
          <span>上传资料</span>
        </div>
      </div>
      <div class="pa-dialog-content text-center document-dialog-file">
        <form name="addForm">
          <div class="pa-form-control pa-width-100">
            <label class="text-right"><b>*</b>资料编号：</label>
            <input type="text" class="form-control-input" ng-model="vm.reqData.documentNumber">
          </div>
          <div class="pa-form-control pa-width-100">
            <label class="text-right"><b>*</b>资料名称：</label>
            <input type="text" class="form-control-input" ng-model="vm.reqData.documentName">
          </div>
          <div class="pa-form-control pa-width-100">
            <label class="text-right"><b>*</b>编制时间：</label>
            <input type="text" class="pa-form-control-input date-picker"
              data-ng-datepicker
              ng-model="vm.reqData.compileTime">
          </div>
          <div class="pa-form-control pa-width-100">
            <label class="text-right">备注：</label>
            <textarea type="text" class="form-control-textarea"
              ng-model="vm.reqData.remark"></textarea>
          </div>
          <div class="pa-form-control pa-width-100">
            <label class="text-right">附件：</label>
            <div class="pa-operate-add fs-14 fs-theme-color dialog-file-btn">
              <a class="pa-btn-a"
                attachment-uploader
                data-url="/api/v1/common/uploadFile?folderName=document"
                data-target=".file-list"
                ng-model="vm.view.attachmentFiles">
                <span>上传附件</span>
              </a>
            </div>
            <div class="file-list" style="min-height: 30px;">
              <div class="upload-result">
                <div class="result-item" ng-repeat="file in vm.view.attachmentFiles">
                  <span class="file-name">{{file.name}}</span>
                  <span>{{file.humanSize}}</span>
                  <i class="fa fa-times-circle file-remove-btn" ng-click="$removeFile(file);"></i>
                  <span ng-if="file.success === false">上传失败</span>
                  <progress ng-if="file.isUploading" class="progress-bar" value="{{file.loaded}}" max="{{file.size}}"></progress>
                </div>
              </div>
            </div>
          </div>
        </form>
      </div>
      <div class="pa-dialog-footer text-center">
        <a class="pa-btn" ng-click="vm.submitForm(addForm)">
          <span>确定</span>
        </a>
        <a class="pa-btn reset-btn" ng-click="closeThisDialog()">
          <span>取消</span>
        </a>
      </div>
    </div>
  </script>

  <!-- 编辑弹窗 -->
  <script type="text/ng-template" id="paEditDialog">
    <div class="pa-dialog">
      <div class="pa-dialog-header">
        <div class="title-txt">
          <span>修改资料</span>
        </div>
      </div>
      <div class="pa-dialog-content text-center document-dialog-file">
        <div class="pa-form-control pa-width-100">
          <label class="text-right"><b>*</b>资料编号：</label>
          <input type="text" class="form-control-input"
            ng-model="vm.document.documentNumber">
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right"><b>*</b>资料名称：</label>
          <input type="text" class="form-control-input"
            ng-model="vm.document.documentName">
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right"><b>*</b>编制时间：</label>
          <input type="text" class="pa-form-control-input date-picker"
            data-ng-datepicker
            ng-model="vm.document.compileTime">
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right">备注：</label>
          <textarea type="text" class="form-control-textarea"
            ng-model="vm.document.remark"></textarea>
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right">附件：</label>
          <div class="pa-operate-add fs-14 fs-theme-color dialog-file-btn">
            <a class="pa-btn-a"
              attachment-uploader
              data-url="/api/v1/common/uploadFile?folderName=document"
              data-target=".file-list"
              ng-model="vm.view.attachmentFiles">
              <span>上传附件</span>
            </a>
          </div>
          <div class="file-list" style="min-height: 30px;">
            <div class="upload-result">
              <div class="result-item" ng-repeat="file in vm.view.attachmentFiles">
                <span class="file-name">{{file.name}}</span>
                <span>{{file.humanSize}}</span>
                <i class="fa fa-times-circle file-remove-btn" ng-click="$removeFile(file);"></i>
                <span ng-if="file.success === false">上传失败</span>
                <progress ng-if="file.isUploading" class="progress-bar" value="{{file.loaded}}" max="{{file.size}}"></progress>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="pa-dialog-footer text-center">
        <a class="pa-btn" ng-click="vm.submitEditForm()">
          <span>确定</span>
        </a>
        <a class="pa-btn reset-btn" ng-click="closeThisDialog()">
          <span>取消</span>
        </a>
      </div>
    </div>
  </script>
</div>